#!/usr/bin/python3
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-

# template metadata.xml
"""
<?xml version="1.0" encoding="utf-8"?>
<plugin>
  <subnetl3-plugin id="ethernet">
    <description>WAN connection by static configuration</description>
    <filename>plugin.py</filename>
    <classname>PluginObject</classname>
  </subnetl3-plugin>
</plugin>
"""

# config file: ${ETC}/plugin-(PLUGIN_NAME)-(INSTANCE_NAME).cfg
# allow multiple plugins be loaded, and one plugin can have multiple instances
class TemplatePluginSubnetl3:

    def disose(self):
        assert False

    def config_changed(self, new_config):
        pass

    def get_all_subnets(self):
        # return dict<subnet-id,subnet-data>
        # returns all the subnets
        pass

    def get_subnet(self, subnet_id):
        # return subnet-data
        """
        subnet-data example:
        {
            "bridge": {
                "ifname": "INTERFACE-NAME",
                "ifconfig": {
                    "inet": {
                        "address": "X.X.X.X",
                        "prefixlen": N,
                    },
                    "inet6": {
                        "address": "X.X.X.X",
                        "prefixlen": N,
                    },
                },
            },
            "subif": [ "INTERFACE-NAME", "INTERFACE-NAME" ],
        }
        """
        pass

    def get_subnet_clients(self, subnet_id):
        # return dict<client-id,client-data>
        # returns all the clients of the specified subnet
        pass

    def get_subnet_client(self, subnet_id, client_id):
        # return client-data
        pass

    def start(self, callbacks):
        assert False

    def stop(self):
        assert False


class TemplatePluginCallback:

    def client_added(self, plugin_id, client_id, client_data):
        pass

    def client_changed(self, plugin_id, client_id, client_data):
        pass

    def client_removed(self, plugin_id, client_id, client_data):
        pass
